package com.jtech.dribbble.util;

import com.jtech.dribbble.net.call.JCall;

import java.util.ArrayList;
import java.util.List;

/**
 * 用于管理请求
 * Created by wuxubaiyang on 16/4/18.
 */
public class RequestManager {
    private List<JCall> jCalls;

    public RequestManager() {
        jCalls = new ArrayList<>();
    }

    /**
     * 添加请求
     *
     * @param jCall
     */
    public void addCall(JCall jCall) {
        if (null != jCall && null != jCalls) {
            jCalls.add(jCall);
        }
    }

    /**
     * 取消全部请求
     */
    public void clearAllCall() {
        if (null != jCalls) {
            for (int i = 0; i < jCalls.size(); i++) {
                JCall jCall = jCalls.get(i);
                if (null != jCall) {
                    jCall.cancel();
                }
            }
        }
    }
}